package factories;

import adress.Adress;
import adress.AdressAmerican;
import adress.AdressFrench;

public class AdressFactory {
	
	/**
	 * Creates an Adress with the format of the specified country as a String and validates it
	 * @param type - the country in witch the address is; adr -  the actual adress
	 * @return new Adress of the specified type;
	 * @return null if the type specified is inexistent or the validation failed
	 */
	public static Adress createDate(String type,String adr){
		Adress ret;
		if (type.equals("american")){
			ret=new AdressAmerican(adr);
			return ret.valid(adr)?ret:null;
		}
		if (type.equals("french")){
			ret=new AdressFrench(adr);
			return ret.valid(adr)?ret:null;
		}
		return null;
	}
}
